package meihua.stopcarapp.model;

import meihua.mylibrary.basebean.ResultModel;
import meihua.mylibrary.baserx.RxSchedulers;
import meihua.stopcarapp.api.Api;
import meihua.stopcarapp.api.URLType;
import meihua.stopcarapp.bean.result.OrderEcodeResult;
import meihua.stopcarapp.presenter.contract.OrderEcodeContract;
import rx.Observable;
import rx.functions.Func1;

/**
 * Name: LGZ
 * Time: 2017/5/19.
 * Dec:
 */

public class OrderEcodeModel implements OrderEcodeContract.Model {

    @Override
    public Observable<OrderEcodeResult> sendOrderEcode(String order_num, String order_monry, String coupon_id, String coupon_gid) {
        return Api.getDefault(URLType.STOPCAR_URL)
                .sendOrderEcode(order_num, order_monry,coupon_id,coupon_gid)
                .map(new Func1<ResultModel<OrderEcodeResult>, OrderEcodeResult>() {
                    @Override
                    public OrderEcodeResult call(ResultModel<OrderEcodeResult> userEntityResultModel) {
                        return userEntityResultModel.getData();
                    }
                })
                .compose(RxSchedulers.<OrderEcodeResult>io_main());
    }
}
